﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using NWN.GDY.Service.Core;
using NWN.GDY.Service.Entity;

namespace NWN.GDY.Web
{
    public partial class Room : PageBase
    {
        protected string RoomName;
        protected string UserNickName;
        protected string RoomGUID;
        protected string CoinName;
        protected int CoinID;
        protected void Page_Load(object sender, EventArgs e)
        {
            //是否有桌号
            string roomguid = Request.QueryString["guid"] == null ? "" : Request.QueryString["guid"].ToString();
            if (!string.IsNullOrEmpty(roomguid))
            {
                //根据桌号取桌信息
                GDYEngine engine = new GDYEngine();
                NWN.GDY.Service.Entity.Room room = engine.GetRoom(roomguid, CurrentUser, 0, null, null, null, null, null, null, 0, null, null,null);
                if (room != null)
                {
                    if (room.Result != 0)
                    {
                        Response.Redirect("main.aspx", true);  
                    }
                    RoomName = room.RoomName;
                    RoomGUID = room.RoomGUID;
                    NWN.GDY.Service.Entity.User user = new UserBC().GetUser(CurrentUser);
                    if (user != null)
                        UserNickName = user.NickName;
                    else
                        UserNickName = "";
                    CoinID = room.CoinID;
                    if (CoinID > 0)
                    {
                        CoinName = new RoomBC().GetCoinName(CoinID);
                    }
                    return;
                }
            }
            //异常流，定向至首页
            Response.Redirect("Default.aspx", true);
        }
    }
}
